package org.ljx.taobao.controller;

import org.ljx.taobao.api.IShoppingService;
import org.ljx.taobao.api.entity.Shopping;
import org.ljx.taobao.service.ShoppingServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author: Ljx
 * @Date: 2021/12/31 11:53
 * @role: 查询某用户订单
 */
@WebServlet("/query")
public class QueryServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;utf-8");
//        HttpSession session = req.getSession();
        IShoppingService iShoppingService = new ShoppingServiceImpl();
        List<Shopping> shopping = iShoppingService.query();

//        session.setAttribute("shop",shopping);
//        resp.sendRedirect("shopping.jsp");
        req.setAttribute("shopList",shopping);
        req.getRequestDispatcher("shopping.jsp").forward(req,resp);
    }
}

